<?php

/*
  Action	$4

  Trash a card from you hand, if it is an...
  Action: +2 actions
  Treasure: +2$
  Victory: +2 cards

 */

class Pacifist extends Card implements iAction, iKingdom, iAddiction {

    public function __construct() {
        parent::__construct("Pacifist", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "Trash a card from you hand, if it is an...  Action: +2 actions,  Treasure: +2$,  Victory: +2 cards");
    }

    public function play(Game $game, $isRealCard) {

        $playhand = $game->getPlayHand();

        if (sizeof($playhand) > 0) {

            $playhand = getUniqueCards($playhand);
            if (sizeof($playhand) > 1) {
                $output = MySocket::GetUserReply($game, Input_ChooseOne, $playhand, 1, 1, null, "Choose a card to trash");
                $old_card_name = $output[0];
            }
            else {
                $old_card_name = $playhand[0];
            }
            
            $old_card = $game->moveCardFromPileToPile($old_card_name, PlayHand, Trash);
            ScreenDisplay::addScreenMessage($game, true, "trash " . nicePrint($old_card), "trashes " . ScreenDisplay::$LMSG);

            if ($old_card instanceof iAction) {
                $game->addActions(2);
                ScreenDisplay::addScreenMessage($game, false, " and get +2 actions", " and gets +2 actions");
            }

            if ($old_card instanceof iTreasure) {
                $game->addMoney(new Price(2));
                ScreenDisplay::addScreenMessage($game, false, " and get +2$", " and gets +2$");
            }

            if ($old_card instanceof iVictory) {
                $drawed_cards = $game->drawCards(2);
                ScreenDisplay::addScreenMessage($game, false, " and draw " . nicePrint($drawed_cards), " and draws " . sizeof($drawed_cards) . " cards");
            }
        }

        $game->cardActionFinished();
        return true;
    }

}

?>